package com.lz.comm.net

import androidx.annotation.IntDef
import com.lz.library.proguard.IProguardField

/**
 * 可用此判断分页与刷新添加操作
 */
data class PagingList<T>(
    var page: Int = 0,
    var pageNum: Int = 0,
    var total: Int = 0,
    var list: MutableList<T>? = null
) : IProguardField {

    @IntDef(MORE, END)
    @Retention(AnnotationRetention.SOURCE)
    annotation class PageState

    //判断刷新后是否要滑动到起始位置
    var isRefreshing = false

    fun hasNext(): Boolean = pageNum > page

    fun isFirstPage(): Boolean = page == 1

    fun isNotEmpty(): Boolean = list?.isNotEmpty() == true

    @PageState
    fun pageState(): Int = if (hasNext()) MORE else END

    companion object {
        const val MORE = 0
        const val END = 1
    }
}